{extend name="layout" /}
{block name="content"}
<div class="main">
    <div class="headerbanner">
        <div class="headerbanner-img">
            <img src="__STATIC__/images/item1/item01.jpg" />
        </div>
        <div class="crumbs">
            <div class="container">
                <div class="row">
                    <div class="left">
                        <span class="icon iconfont icon-shouye"></span>
                        <span>新闻中心 > 重要新闻</span>
                    </div>
                    <div class="right">
                        <a class="active" href="javascript:;">重要新闻</a>
                        <a href="javascript:;">项目动态</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="contact">
        <div class="container">
            <div class="row">
                <div class="contact-left">
                    {if condition="0"}
                    <div class="top">
                        <img src="{$t.poster}" width="276" height="185" />
                        <div class="topbody">
                            <h4>{$t.create_time|date="Y/m/d",###}</h4>
                            <h4>{$t.title}</h4>
                            <p>{$t.description}</p>
                            <a href="/post/{$t.id}">了解更多</a>
                        </div>
                    </div>
                    {/if}
                    <ul class="middle" id="postList">
                        {volist name="posts->items()" id="vo"}
                        <li>
                            <a href="/post/{$vo.id}">
                                <p class="left">{$vo.create_time|date="d",###}<span>{$vo.create_time|date="Y-m",###}</span></p>
                                <p class="right">
                                    <span class="title">{$vo.title}</span>
                                    <span class="text">{$vo.description}</span>
                                </p>
                            </a>
                        </li>
                        {/volist}
                    </ul>
                    <div class="jagd" id="getMore">
                        点击更多
                    </div>
                </div>
                <div class="contact-right">
                    <ul>
                        {volist name="proxy" id="vo"}
                        <li>
                            <a href="{$vo.url}" target="_blank">
                                <img src="{$vo.poster}">
                                <span>{$vo.name}</span>
                            </a>
                        </li>
                        {/volist}
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script>
    var page = 0;
    $('#getMore').on('click', function () {
        page++;
        $.ajax({
            url: '/post/page/' + page,
            success: function (res) {
                if (res.code == 0) {
                    for (var i in res.data) {
                        var html = '<li>';
                        html += '<a href="/post/'+ res.data[i].id +'">';
                        html += '<p class="left">'+ format(res.data[i].create_time, 1) +'<span>'+ format(res.data[i].create_time, 2) +'</span></p>';
                        html += '<p class="right"><span class="title">'+ res.data[i].title +'</span><span class="text">'+ res.data[i].description +'</span></p>'
                        html += '</a>';
                        html += '</li>';
                        $('#postList').append(html);
                    }
                }
            }
        })
    });
    function format(time, type) {
        time = new Date(time * 1000);
        var year = time.getFullYear();
        var month = time.getMonth() + 1;
        var date = time.getDate();
        if (type === 1) {
            return date;
        } else {
            return year + '-' + month;
        }
    }
</script>
{/block}